<%-- 
    Document   : salesentrydb
    Created on : Jan 14, 2013, 9:10:58 PM
    Author     : Bittuji
--%>

<%@page import="java.text.SimpleDateFormat"%>
<%@page contentType="text/html" pageEncoding="UTF-8" import="java.util.Date"%>
<%@include  file="db.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
        
        SimpleDateFormat format1 = new SimpleDateFormat("dd-MM-yyyy");
        Date date1 = format1.parse(request.getParameter("date"));
        java.sql.Date cdate = new java.sql.Date(date1.getTime());
        
        
        String pbillno = request.getParameter("pbillno");
        String prname = request.getParameter("prname");
        String prid = request.getParameter("prid");
        
        SimpleDateFormat format2 = new SimpleDateFormat("dd-MM-yyyy");
        Date date2 = format2.parse(request.getParameter("purdate"));
        java.sql.Date purdate = new java.sql.Date(date2.getTime());
        
        
        SimpleDateFormat format3 = new SimpleDateFormat("dd-MM-yyyy");
        Date date3 = format3.parse(request.getParameter("trdate"));
        java.sql.Date trdate = new java.sql.Date(date3.getTime());
        
        
        int crday = Integer.parseInt(request.getParameter("crday"));
        float amt = Float.parseFloat(request.getParameter("amt"));
        
        String sql = "INSERT INTO `purchase_entry`(`date`, `purchase_billno`, `party_name`, `party_id`, `purchase_date`, `tra_date`, `credit_day`, `amount`) VALUES (?,?,?,?,?,?,?,?)";
        
        PreparedStatement pstmt = con.prepareStatement(sql);
       
        pstmt.setDate(1, cdate);
        pstmt.setString(2, pbillno);
        pstmt.setString(3, prname);
        pstmt.setString(4, prid);
        pstmt.setDate(5, purdate);
        pstmt.setDate(6, trdate);
        pstmt.setInt(7, crday);
        pstmt.setFloat(8, amt);
        
        int result = pstmt.executeUpdate();
        
        if(result==1)
            System.out.println("DATA INSERTED");
        
        %>
    </body>
</html>
